package com.mallcloud.mall.mall.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mallcloud.mall.common.core.util.R;
import com.mallcloud.mall.common.excel.annotation.ResponseExcel;
import com.mallcloud.mall.mall.api.entity.XglParkingRedeemSettingModel;
import com.mallcloud.mall.mall.service.XglParkingRedeemSettingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "mall-星光里停车兑换设置")
@RestController
@RequiredArgsConstructor
@RequestMapping("/mall/xglParkingSetting")
public class XglParkSettingController {
	private final XglParkingRedeemSettingService xglParkingRedeemSettingService;

    @ApiOperation("分页")
    @GetMapping("/page")
    @PreAuthorize("@pms.hasPermission('mall_xglparkingsetting_view')")
    public R<IPage<XglParkingRedeemSettingModel>> page(Page<XglParkingRedeemSettingModel> page, XglParkingRedeemSettingModel dto) {
        return R.ok(xglParkingRedeemSettingService.page(page, Wrappers.lambdaQuery(dto)));
    }

	@ApiOperation("列表")
	@GetMapping("/list")
	@PreAuthorize("@pms.hasPermission('mall_xglparkingsetting_view')")
	public R<List<XglParkingRedeemSettingModel>> list(XglParkingRedeemSettingModel dto) {
		return R.ok(xglParkingRedeemSettingService.list(Wrappers.lambdaQuery(dto)));
	}

    @ApiOperation("查询详情")
    @GetMapping("/getInfo")
    @PreAuthorize("@pms.hasPermission('mall_xglparkingsetting_view')")
    public R<XglParkingRedeemSettingModel> getInfo(XglParkingRedeemSettingModel dto) {
        return R.ok(xglParkingRedeemSettingService.getById(Wrappers.lambdaQuery(dto.getActivityId())));
    }

    @ApiOperation("修改")
	@PostMapping("/update")
    @PreAuthorize("@pms.hasPermission('mall_xglparkingsetting_edit')")
    public R<Boolean> update(@RequestBody XglParkingRedeemSettingModel dto) {
        return R.ok(xglParkingRedeemSettingService.updateById(dto));
    }

	@ApiOperation("导出")
    @ResponseExcel
    @GetMapping("/export")
    @PreAuthorize("@pms.hasPermission('mall_xglparkingsetting_export')")
    public List<XglParkingRedeemSettingModel> export(XglParkingRedeemSettingModel dto) {
        return xglParkingRedeemSettingService.list(Wrappers.lambdaQuery(dto));
    }
}
